home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / except.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  3.1 KB  |  151 lines

  1. /*  except.h
  2.  
  3.     Definitions for exception handling
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 9.0
  9.  *
  10.  *      Copyright (c) 1992, 1998 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14. /* $Revision:   9.13  $ */
  15.  
  16.  
  17. #ifndef __EXCEPT_H
  18. #define __EXCEPT_H
  19.  
  20. #ifndef __cplusplus
  21. #  error Must use C++ for except.h
  22. #endif
  23.  
  24. #if !defined(___STDLIB_H)
  25. #  include <stdlib.h>
  26. #endif
  27.  
  28. #if !defined(__STD_EXCEPTION)
  29. #  include <exception>
  30. #endif
  31.  
  32. // forward declare string
  33. namespace std {
  34.  
  35. template<class charT> struct _RWSTDExportTemplate char_traits;
  36. template<class T> class _RWSTDExportTemplate allocator;
  37.  
  38. template<class charT, class traits, class Allocator> class _RWSTDExportTemplate
  39. basic_string;
  40.  
  41. typedef basic_string<char, char_traits<char>, allocator<char> > string;
  42.  
  43. }
  44.  
  45. using std::string;
  46.  
  47. #if !defined(RC_INVOKED)
  48.  
  49. #pragma pack(push, 1)
  50. #pragma option push -Vo-     // set standard C++ options
  51.  
  52. #if defined(__STDC__)
  53. #pragma warn -nak
  54. #endif
  55.  
  56. #endif  /* !RC_INVOKED */
  57.  
  58.  
  59. typedef void (_RTLENTRY *terminate_handler)();
  60. typedef void (_RTLENTRY *unexpected_handler)();
  61.  
  62. #ifndef __STDC__
  63. // For backwards compatibility ...
  64. typedef unexpected_handler unexpected_function;
  65. typedef terminate_handler terminate_function;
  66. #pragma obsolete terminate_function
  67. #pragma obsolete unexpected_function
  68. #endif // !__STDC__
  69.  
  70. terminate_handler  _RTLENTRY set_terminate(terminate_handler);
  71. unexpected_handler _RTLENTRY set_unexpected(unexpected_handler);
  72.  
  73. void  _RTLENTRY terminate();
  74. void  _RTLENTRY unexpected();
  75.  
  76.  
  77. extern  char *      _RTLENTRY __ThrowFileName();
  78. extern  unsigned    _RTLENTRY __ThrowLineNumber();
  79. extern  char *      _RTLENTRY __ThrowExceptionName();
  80.  
  81. #define  __throwFileName      __ThrowFileName()
  82. #define  __throwLineNumber    __ThrowLineNumber()
  83. #define  __throwExceptionName __ThrowExceptionName()
  84.  
  85. class _EXPCLASS xmsg : public std::exception
  86. {
  87. public:
  88.     xmsg(const std::string &msg);
  89.     xmsg(const xmsg &);
  90.     virtual ~xmsg() throw();
  91.     xmsg & operator=(const xmsg &);
  92.  
  93.     virtual const char * what() const throw();
  94.     const std::string & why() const;
  95.     void                raise() throw(xmsg);
  96.  
  97. private:
  98.     std::string *str;
  99. };
  100.  
  101. inline const std::string & xmsg::why() const
  102. {
  103.     return *str;
  104. };
  105.  
  106. /* The xalloc class is here for backwards compatibility ONLY!  Operator new
  107.    will not throw one of these anymore.  Operator new now throws a bad_alloc
  108.    instead.
  109. */
  110.  
  111. class _EXPCLASS xalloc : public xmsg
  112. {
  113. public:
  114.     xalloc(const std::string &msg, _SIZE_T size);
  115.  
  116.     _SIZE_T requested() const;
  117.     void    raise() throw(xalloc);
  118.  
  119. private:
  120.     _SIZE_T siz;
  121. };
  122.  
  123.  
  124. inline xalloc::xalloc(const std::string &msg, _SIZE_T size)
  125.     : xmsg(msg), siz(size)
  126. {
  127. }
  128.  
  129. inline _SIZE_T xalloc::requested() const
  130. {
  131.     return siz;
  132. }
  133.  
  134. #pragma obsolete xalloc
  135. #pragma obsolete xmsg
  136.  
  137. #if !defined(RC_INVOKED)
  138.  
  139. #if defined(__STDC__)
  140. #pragma warn .nak
  141. #endif
  142.  
  143. #pragma option pop      // restore user C++ options
  144. /* restore default packing */
  145. #pragma pack(pop)
  146.  
  147. #endif  /* !RC_INVOKED */
  148.  
  149.  
  150. #endif  // __EXCEPT_H
  151.